What is the proper way to use string::find to look for a word? [migrated]

Posted by RubyKing on Game Development See other posts from Game Development or by RubyKing
Published on 2012-04-02T11:07:10Z Indexed on 2012/04/02 17:42 UTC
Read the original article Hit count: 136

Filed under:

How would I look through a string for a word rather then each character in that word. I have my code here and it always seems to find everything that is .obj even if its o or b or j or "." I checked the docuementation here but was unable to find an answer. Here is my code:

 string &str = *it;

 if(it->find(".obj"))
 {
     cout << "Found .Obj" << endl;
 }

I also tried to use string::compare but that failed.

© Game Development or respective owner

Related posts about c++